package textFile;
import java.io.*;

public class ReadFile {
	public String path;
	
	public ReadFile(String filePath)
	{
	    path = filePath;	
	}
	
	public String[] openFile() throws IOException
	{
		FileReader f = new FileReader(path);
		BufferedReader textReader = new BufferedReader(f);
		
		int numberOfLines = countLines();
		String[] fileData = new String[numberOfLines];
		
		for(int i=0; i<numberOfLines; i++)
		{
		    fileData[i] = textReader.readLine();	
		}
		
		textReader.close();
		return fileData;
	}
	
	public int countLines() throws IOException
	{
		FileReader fr = new FileReader(path);
		BufferedReader bf = new BufferedReader(fr);
		
		String line;
		int numberOfLines = 0;
		
		while((line = bf.readLine()) != null)
		{
			numberOfLines++;
		}
		bf.close();
		
		return numberOfLines;
	}

}
